package com.tz.farmer.service.impl;

import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.mapper.GoodsInfoMapper;
import com.tz.farmer.service.DoorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class DoorServiceImpl implements DoorService {
    private static Logger logger = LoggerFactory.getLogger(DoorServiceImpl.class);


    @Autowired
    GoodsInfoMapper goodsInfoMapper;

    @Override
    public ResultEx getStatisticsInfo() throws Exception{
        Map resultMap=new HashMap<>();
        //查询台农链激活主体数
        int farmerMainCount=goodsInfoMapper.selectMainCount();
        //查询台农链访问次数
        int farmerVisitCount=goodsInfoMapper.selectVisitCount();
        //查询台农链激活批次数(激活产品种类数)
        int farmerBatchCount=goodsInfoMapper.selectBatchCount();


        //查询台渔链激活主体数
        int fishMainCount=goodsInfoMapper.selectFishMainCount();
        //查询台渔链访问次数
        int fishVisitCount=goodsInfoMapper.selectFishVisitCount();
        //查询台渔链激活批次数(激活产品种类数)
        int fishBatchCount=goodsInfoMapper.selectFishBatchCount();
        resultMap.put("mainCount",fishMainCount+15+farmerMainCount+15);
        resultMap.put("visitCount",fishVisitCount+800+farmerVisitCount+800);
        resultMap.put("batchCount",fishBatchCount+15+farmerBatchCount+20);
        resultMap.put("typeCount",fishBatchCount+2+farmerBatchCount+4);

        return ResultEx.builder().makeSuccessResult(resultMap);
    }


    @Override
    public ResultEx getShareInfo() throws Exception{
        Map resultMap=new HashMap<>();
        //查询浙食链共享数据
        int farmerGoodsCount=goodsInfoMapper.selectGoodsCount();
        //查询浙农码
        int farmerMainCount=goodsInfoMapper.selectMainCount();
        //浙食链
        resultMap.put("zsl",farmerGoodsCount);
        resultMap.put("znm",farmerMainCount);
        //船港通
        resultMap.put("cgt",2748319);
        //渔货物
        resultMap.put("yhw",23090);
        return ResultEx.builder().makeSuccessResult(resultMap);
    }

}
